﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.Common;
using DataAccessClasses;

namespace websoniBO
{
    public class Comments
    {
        iDAC DAC = DACFactory.GetDAC();
        private long _cid = -99;
        private string _sender_name = "";
        private string _comment = "";
        private bool _isdeleted = false;
        public long cid
        {
            get
            {
                return _cid;
            }
            set
            {
                _cid = value;
            }
        }
        public string sender_name
        {
            get
            {
                return _sender_name;
            }
            set
            {
                _sender_name = value;
            }
        }
        public string comment
        {
            get
            {
                return _comment;
            }
            set
            {
                _comment= value;
            }
        }
        public bool isdeleted
        {
            get
            {
                return _isdeleted;
            }
            set
            {
                _isdeleted = value;
            }
        }
        public long SaveRecords()
        {
            try
            {
                DbParameter dbparam0 = DAC.Parameter("@cid", cid, DbType.Int64, ParameterDirection.Input);
                DbParameter dbparam1 = DAC.Parameter("@sender_name", sender_name, DbType.AnsiString, ParameterDirection.Input);
                DbParameter dbparam2 = DAC.Parameter("@comment", comment, DbType.AnsiString, ParameterDirection.Input);
                DbParameter dbparam3 = DAC.Parameter("@isdeleted", isdeleted, DbType.Boolean, ParameterDirection.Input);
                DbParameter[] dbparamcall = new DbParameter[] { dbparam0, dbparam1,dbparam2, dbparam3 };
                return DAC.Save("comments_save", dbparamcall);
            }
            catch (Exception ex)
            {
                long Result = -99;
            }
            return -99;
        }
        public DataTable GetRecords(long cid, string sender_name, string comment, bool isdeleted, string paraandor)
        {
            try
            {
                DbParameter dbparam0 = DAC.Parameter("@cid", cid, DbType.Int64, ParameterDirection.Input);
                DbParameter dbparam1 = DAC.Parameter("@sender_name", sender_name, DbType.AnsiString, ParameterDirection.Input);
                DbParameter dbparam2 = DAC.Parameter("@comment", comment, DbType.AnsiString, ParameterDirection.Input);
                DbParameter dbparam3 = DAC.Parameter("@isdeleted", isdeleted, DbType.Boolean, ParameterDirection.Input);
                DbParameter dbparam4 = DAC.Parameter("@paraandor", paraandor, DbType.AnsiString, ParameterDirection.Input);
                DbParameter[] dbparamcall = new DbParameter[] { dbparam0, dbparam1,dbparam2 ,dbparam3, dbparam4 };
                DataTable dt1 = DAC.Select("comments_get", dbparamcall);
                return dt1;
            }
            catch (Exception ex)
            {
                long Result = -99;
            }
            return null;
        }
    }
}
